package com.linwen.excise.leetcode;

/**
 * @ClassName _1822数组元素积的符号
 * @Description TODO
 * @Author zero
 * @DATE 2024/9/28 5:26 PM
 * @Version 1.0
 */
public class _1822数组元素积的符号 {
    public static void main(String[] args) {
        _1822数组元素积的符号 inst = new _1822数组元素积的符号();
        int[] nums = {-1,-2,-3,-4,3,2,1};
        System.out.println(inst.arraySign(nums));
    }
    public int arraySign(int[] nums) {
        int temp = 1;
        for (int num : nums) {
            if (num == 0) {
                return 0;
            }
            if (num < 0) {
                temp = -temp;
            }
        }
        return temp;
    }
}
